package day05_api.com.itheima.d5_regex;

import java.util.Scanner;

public class Regex_Test3 {
    public static void main(String[] args) {
//        checkPhone();

        checkEmail();
    }

    public static void checkPhone(){
        while ( true){
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入手机号码：");
            String phone = sc.next();
            if (phone.matches("1[3-9]\\d{9}")){
                System.out.println("手机号码合法！");
            }else {
                System.out.println("手机号码不合法！");
            }
        }
    }

    public static void checkEmail(){
        while ( true){
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入邮箱：");
            String email = sc.next();
            if (email.matches("\\w+@\\w+\\.\\w+")){
                System.out.println("邮箱合法！");
            }else {
                System.out.println("邮箱不合法！");
            }
        }
    }
}
